//
//  HNSH_RefundDetailHeaderView.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/3/6.
//

#import "HNSH_RefundDetailHeaderView.h"
#import "HNSH_RefundDetailShopView.h"

@interface HNSH_RefundDetailHeaderView ()
/**  */
@property (nonatomic, strong)UIImageView * bgView;
/**  */
@property (nonatomic, strong)UIView * statusView;
/**  */
@property (nonatomic, strong)UILabel * statusLabel;
/**  */
@property (nonatomic, strong)UILabel * timeLabel;
/**  */
@property (nonatomic, strong)UIView * moneyView;
/**  */
@property (nonatomic, strong)UIImageView * moneyImgView;
/**  */
@property (nonatomic, strong)UILabel * moneyDesLabel;
/**  */
@property (nonatomic, strong)UILabel * moneyLabel;
/**  */
@property (nonatomic, strong)HNSH_RefundDetailShopView * shopView;
@end

@implementation HNSH_RefundDetailHeaderView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self configUI];
    }
    return self;
}

- (void)configUI {
    [self addAllViews];
    [self addAllLayout];
}

//MARK: Cycle Methods
- (void)addAllViews{
    self.backgroundColor = [UIColor clearColor];
    [self addSubview:self.bgView];
    [self.bgView addSubview:self.statusView];
    [self.statusView addSubview:self.statusLabel];
    [self.statusView addSubview:self.timeLabel];
    [self.bgView addSubview:self.moneyView];
    [self.moneyView addSubview:self.moneyImgView];
    [self.moneyView addSubview:self.moneyDesLabel];
    [self.moneyView addSubview:self.moneyLabel];
    [self addSubview:self.shopView];
}

- (void)addAllLayout{
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(0);
        make.height.mas_equalTo(kNavBarAndStatusBarHeight + 32 + 80);
    }];
    [self.statusView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.right.mas_equalTo(-16);
        make.height.mas_equalTo(80);
        make.top.mas_equalTo(16+kNavBarAndStatusBarHeight);
    }];
    [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(20);
        make.height.mas_equalTo(22);
    }];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(self.statusLabel.mas_bottom).offset(2);
        make.height.mas_equalTo(17);
    }];
    [self.moneyView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(self.bgView.mas_bottom).offset(8);
    }];
    [self.moneyImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.width.height.mas_equalTo(20);
        make.centerY.mas_equalTo(0);
    }];
    [self.moneyDesLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.moneyImgView.mas_right).offset(8);
        make.top.height.mas_equalTo(self.moneyView);
    }];
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-16);
        make.top.height.mas_equalTo(self.moneyView);
    }];
    [self.shopView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(160);
        make.bottom.mas_equalTo(-8);
    }];
}

//MARK: Setter Methods
- (void)setModel:(HNSH_RefundDetailModel *)model{
    _model = model;

    self.statusLabel.text = model.top_title;
    self.timeLabel.text = model.top_desc;
    if (model.middle_show) {
        self.moneyView.hidden = NO;
        self.moneyDesLabel.text = model.middle_title;
        self.moneyLabel.attributedText = [NSString transAttWithSting:model.middle_desc];
    } else {
        self.moneyView.hidden = YES;
    }
    self.shopView.model = model;
}

//MARK: Getter Methods
- (UIImageView *)bgView{
    if (!_bgView) {
        _bgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"mine_order_detail_top_bg"]];
    }
    return _bgView;
}

- (UIView *)statusView{
    if (!_statusView) {
        _statusView = [UIView new];
        _statusView.backgroundColor = [UIColor whiteColor];
        _statusView.layer.cornerRadius = 9;
        _statusView.layer.masksToBounds = YES;
    }
    return _statusView;
}

- (UILabel *)statusLabel{
    if (!_statusLabel) {
        _statusLabel = [UILabel new];
        _statusLabel.font = [UIFont boldSystemFontOfSize:16];
        _statusLabel.textColor = [UIColor appBlack333LabelColor];
    }
    return _statusLabel;
}

- (UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = [UILabel new];
        _timeLabel.font = [UIFont systemFontOfSize:12];
        _timeLabel.textColor = [UIColor colorWithHexString:@"#999999"];
    }
    return _timeLabel;
}

- (UIView *)moneyView{
    if (!_moneyView) {
        _moneyView = [UIView new];
        _moneyView.backgroundColor = [UIColor whiteColor];
    }
    return _moneyView;
}

- (UIImageView *)moneyImgView{
    if (!_moneyImgView) {
        _moneyImgView = [UIImageView new];
        _moneyImgView.image = [UIImage imageNamed:@"shop_tuikuan"];
    }
    return _moneyImgView;
}

- (UILabel *)moneyDesLabel{
    if (!_moneyDesLabel) {
        _moneyDesLabel = [UILabel new];
        _moneyDesLabel.font = [UIFont boldSystemFontOfSize:16];
        _moneyDesLabel.textColor = [UIColor appBlack333LabelColor];
    }
    return _moneyDesLabel;
}

- (UILabel *)moneyLabel{
    if (!_moneyLabel) {
        _moneyLabel = [UILabel new];
        _moneyLabel.font = [UIFont systemFontOfSize:16];
        _moneyLabel.textAlignment = NSTextAlignmentRight;
    }
    return _moneyLabel;
}

- (HNSH_RefundDetailShopView *)shopView{
    if (!_shopView) {
        _shopView = [HNSH_RefundDetailShopView new];
    }
    return _shopView;
}

@end
